/*
 * @Date: 2022-02-28 10:34:57
 * @LastEditors: 春贰
 * @gitee: https://gitee.com/chun22222222
 * @github: https://github.com/chun222
 * @Desc:
 * @LastEditTime: 2022-04-13 17:59:31
 * @FilePath: \server\system\router\sys.go
 */
package router

import (
	"go2admin_pure/system/controller/sys/databackup"
	"go2admin_pure/system/controller/sys/permission"
	"go2admin_pure/system/controller/sys/record"
	"go2admin_pure/system/controller/sys/role"
	"go2admin_pure/system/controller/sys/sysconfig"
	"go2admin_pure/system/controller/sys/sysfile"
	"go2admin_pure/system/controller/sys/user"
	"go2admin_pure/system/middleware"
	"github.com/gin-gonic/gin"
)

func UserRouter(r *gin.Engine) {
	authG := r.Group("user")
	authG.Use(middleware.JwtMid(), middleware.PermissionMid())
	{
		authG.POST("/list", user.List)
		authG.POST("/add", user.Add)
		authG.POST("/edit", user.Edit)
		authG.POST("/remove", user.Romove)
		authG.POST("/permissions", user.Permissions)
		authG.POST("/setpermissions", user.SetPermissions)
		authG.POST("/setroles", user.SetRoles)
		authG.POST("/roles", user.Roles)
		authG.POST("/reloadinfo", user.Reloadinfo)

	}

}

func PermissionRouter(r *gin.Engine) {
	authG := r.Group("permission")
	authG.Use(middleware.JwtMid(), middleware.PermissionMid())
	{
		authG.POST("/tree", permission.Tree)
		authG.POST("/list", permission.List)
		authG.POST("/add", permission.Add)
		authG.POST("/edit", permission.Edit)
		authG.POST("/remove", permission.Romove)
		authG.POST("/copy", permission.Copy)

	}

}

func RoleRouter(r *gin.Engine) {
	authG := r.Group("role")
	authG.Use(middleware.JwtMid(), middleware.PermissionMid())
	{
		authG.POST("/list", role.List)
		authG.POST("/add", role.Add)
		authG.POST("/edit", role.Edit)
		authG.POST("/remove", role.Romove)
		authG.POST("/permissions", role.Permissions)
		authG.POST("/setpermissions", role.SetPermissions)

	}

}

func DatabackupRouter(r *gin.Engine) {
	authG := r.Group("databackup")
	authG.Use(middleware.JwtMid(), middleware.PermissionMid())
	{
		authG.POST("/list", databackup.List)
		authG.POST("/tables", databackup.Tables)
		authG.POST("/add", databackup.Add)
		authG.POST("/restore", databackup.Restore)
		authG.POST("/remove", databackup.Remove)

	}

}

func RecordRouter(r *gin.Engine) {
	authG := r.Group("record")
	authG.Use(middleware.JwtMid(), middleware.PermissionMid())
	{
		authG.POST("/list", record.List)

	}
}

func ConfigRouter(r *gin.Engine) {
	authG := r.Group("config")
	authG.Use(middleware.JwtMid(), middleware.PermissionMid())
	{
		authG.POST("/list", sysconfig.List)
		authG.POST("/add", sysconfig.Add)
		authG.POST("/edit", sysconfig.Edit)
		authG.POST("/remove", sysconfig.Remove)

	}
}

func FileRouter(r *gin.Engine) {
	authG := r.Group("file")
	authG.Use(middleware.JwtMid(), middleware.PermissionMid())
	{
		authG.POST("/list", sysfile.List)
		authG.POST("/upload", sysfile.Upload)
		authG.POST("/createdir", sysfile.CreateDir)
		authG.POST("/remove", sysfile.Remove)

	}
}
